package com.example.demo.bean;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: ShopConfig
 * @Description: 商店全局配置
 * @Author: Administrator
 * @Date: Created in 2022/11/19 19:29
 */
public class ShopConfig {

    //是否满减
    private Boolean isFullReduction = false;
    //满减规则
    private Map<BigDecimal, BigDecimal> reductionRules = Maps.newHashMap();
    //满减的顺序List
    private List<BigDecimal> reductionList = Lists.newArrayList();

    private ShopConfig() {

    }

    private volatile static ShopConfig shopConfig = null;

    //双重校验锁
    public static ShopConfig getInstance() {
        if (shopConfig == null) {
            synchronized (ShopConfig.class) {
                if (shopConfig == null) {
                    shopConfig = new ShopConfig();
                }
            }
        }
        return shopConfig;
    }

    public Boolean getFullReduction() {
        return isFullReduction;
    }

    public void setFullReduction(Boolean fullReduction) {
        isFullReduction = fullReduction;
    }

    public Map<BigDecimal, BigDecimal> getReductionRules() {
        return reductionRules;
    }

    public void setReductionRules(Map<BigDecimal, BigDecimal> reductionRules) {
        this.reductionRules = reductionRules;
    }

    public List<BigDecimal> getReductionList() {
        return reductionList;
    }

    public void setReductionList(List<BigDecimal> reductionList) {
        this.reductionList = reductionList;
    }
}
